from utils.global_utils import *


def events_5col_to_4col(events: np.ndarray) -> np.ndarray:
    dtype = np.float64
    N, _ = events.shape
    res = np.zeros((N, 4), dtype = dtype)
    res[:, 0] = events[:, 0].astype(dtype) + events[:, 1].astype(dtype) * 1e-9
    res[:, 1:] = events[:, 2:].astype(dtype)
    return res


def events_4col_to_5col(events: np.ndarray) -> np.ndarray:
    dtype = np.uint32
    N, _ = events.shape
    res = np.zeros((N, 5), dtype = dtype)
    res[:, 0] = secs(events[:, 0]).astype(dtype)
    res[:, 1] = nsecs(events[:, 0]).astype(dtype)
    res[:, 2:] = events[:, 1:].astype(dtype)
    return res